#ifndef RAWPARSER_H
#define RAWPARSER_H

#endif // RAWPARSER_H
#pragma once
#include <string>
#define IN
#define OUT
#define _CET_SECURE_NO_WARNINGS

struct RectArea
{
    int x;
    int y;
    int w;
    int h;
};

struct PixPoint
{
    int x;
    int y;
};

struct PixTemperature
{
    PixPoint point;
    int temperature;//tenfold
};

class RawParser
{
public:

    RawParser(const char* filePath, int width, int height);
    ~RawParser();

    //将raw文件内容加载到内存中再进行操作和计算
    bool preloadRaw();  

    //将像素点的坐标转换为内存索引
    long pointToIndex(int x, int y);
    //通过像素的坐标xy获取对应的温度，temperature为10倍温度的整数（温度取1位有效位）
    bool getPointTemperature(int x IN, int y IN, int& temperature OUT);//tenfold
    //计算指定范围内像素点温度的平均值、最高值、最高值坐标、最低值、最低值坐标
    bool rangeCaculate(RectArea rect IN, float& temperature OUT, PixTemperature& maxPT OUT, PixTemperature& minPT OUT);
    //rect的宽高应大于0
    bool rangeCaculate(RectArea rect IN, float& temperature OUT);

private:
    FILE* m_imageFP;
    int m_imageW;
    int m_imageH;
    size_t m_fileSize;
    bool m_bHasPreload;
    std::string m_rawData;
};

